package com.ll.stringbufferdemo;

/**
 * @author 刘龙
 * @version 1.0
 */
public class StringBuffer02 {
    public static void main(String[] args) {
        StringBuffer stringBuffer = new StringBuffer();
        // 添加
        stringBuffer.append("java");
        stringBuffer.append(",");
        stringBuffer.append("python");
        // java,python
        System.out.println(stringBuffer);

        // 删除
        stringBuffer.delete(1,3);
        // ja,python
        System.out.println(stringBuffer);

        // 修改
        stringBuffer.replace(2,4,"ll");
        // jallython
        System.out.println(stringBuffer);

        // 查找指定子串第一次出现的索引
        int indexOf = stringBuffer.indexOf("al");
        // 1
        System.out.println(indexOf);

        // 插入
        stringBuffer.insert(2,"va");
        // javallython
        System.out.println(stringBuffer);

        // 获取长度
        // 11
        System.out.println(stringBuffer.length());
    }
}
